//发送Ajax请求数据
// https://edu.telking.com/api/?type=week
// "https://edu.telking.com/api/?type=month"

function request(url) {
    let xhr = new XMLHttpRequest();
    xhr.open("GET",  "https://edu.telking.com/api/?type=month");
    xhr.responseType = "json";
    xhr.send();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200) {
                window.sessionStorage.setItem("seriesLine", JSON.stringify(xhr.response.data.series))
                window.sessionStorage.setItem("xAxisLine", JSON.stringify(xhr.response.data.xAxis))
            }
        }
    }
}

function requestCircul(){
    let xhr = new XMLHttpRequest();
    xhr.open("GET",  "https://edu.telking.com/api/?type=week");
    xhr.responseType = "json";
    xhr.send();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200) { 
                let seriesCircule=xhr.response.data.series;
                let xAxisCircule=xhr.response.data.xAxis;
                window.sessionStorage.setItem("seriesCircule",JSON.stringify(seriesCircule))
                window.sessionStorage.setItem("xAxisCircule",JSON.stringify(xAxisCircule))
            }
        }
    }
}

request();
requestCircul();

// 重新加载一次
function reurl(){
    url=location.href;
    let times=url.split("?");
    if(times[times.length-1]!=1){
        url+="?1";
        setTimeout(function(){
            self.location.replace(url)
        },50)
        
    }
}
window.onload=function(){
    setTimeout(reurl,50);
}